<template>
    <div id="app">
    <div>
      <div style="display: inline-block" v-for='item in arr' :key = 'item.id'>
        <input type="checkbox" :value ='item' v-model="sum" />
        <span>{{item}}</span>
      </div>
      <p>你选中的元素, 累加的值和为: {{total }}</p>
    </div>
  </div>
</template>

<script>
// import dayjs from 'dayjs'
export default {
   data(){
      return{
         sum:[],
         arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      }
   },
  
//   计算属性
computed:{
   total(){
       return this.sum.reduce((t,c)=> t+ c,0)
   }
}
}
</script>

<style>
 
</style>